package com.jxust.service.impl;

import com.jxust.mapper.EmpMapper;
import com.jxust.pojo.JobOption;
import com.jxust.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper  empMapper;
    @Override
    public JobOption getEmpJobData() {
        //1.调用mapper接口获取数据
        List<Map<String,Object>> list = empMapper.countEmpJobData();

        //2.组装结果，返回
        List<Object> jobList = list.stream().map(dataMap -> dataMap.get("pos")).collect(Collectors.toList());
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("num")).collect(Collectors.toList());

        return new JobOption(jobList, dataList);
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        return empMapper.countEmpGenderData();
    }
}
